Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(document): avoid massive perf degradation when saving new doc with 10 level deep subdocs #14910

Merged
merged 5 commits into from
Sep 25, 2024

Conversation

vkarpov15
Copy link
Collaborator

Fix #14897

Summary

Saving a new doc with many very deep subdocs is extremely expensive: the test case in this PR fails after 35 seconds on my local without the change I made to lib/document.js. Saving a new doc 10 levels deep is still more expensive than I'd like, this test now takes maybe 300ms, I'll investigate why this is so slow and add a benchmark.

Examples

Copy link
Collaborator

@hasezoey hasezoey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, will this be in the next minor version for caution?

@vkarpov15
Copy link
Collaborator Author

I don't think it is necessary to put this change in a minor release. As far as I can tell, there's no observable difference with the changes in this PR other than perf improvements. Subdoc middleware and getters will still get called normally, this PR just removes a bunch of work.

@vkarpov15
Copy link
Collaborator Author

No meaningful change on insertManySimple benchmark. But createDeepNestedDocArray benchmark difference is massive: 223ms vs 34802ms on master on 10 level deep subdocs. Over 100x speedup 😎

@vkarpov15 vkarpov15 merged commit 34ed360 into master Sep 25, 2024
46 checks passed
@vkarpov15 vkarpov15 added this to the 8.6.4 milestone Sep 25, 2024
@hasezoey hasezoey deleted the vkarpov15/gh-14897 branch September 26, 2024 10:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Infinitely hangs inserting complex document with recursive schema
2 participants